<?php
if(!check_manager_login()) exit('无权查看，请登录!');
require_once(MODEL_PATH.DS.'Category.php');
$Category = new Category();

if(check_post()){
	$now = date('Y-m-d H:i:s');
	$data = array(
		'name'=>trim($_POST['name']),
		'parent_id'=>$_POST['parent'],
		'description'=>trim($_POST['description']),
		'sort_order'=>trim($_POST['sort']),
		'date_added'=>$now,
		'date_modified'=>$now,
		'status'=>$_POST['state'],
	);
	$result = $Category->addCategory($data);
	redirect('index.php?mod=category&act=list','添加成功！');
}
$def_id = isset($_GET['pid'])?(int)$_GET['pid']:'';
$cat_sel = $Category->getCatSelect($def_id);

include load_tpl('category_add');

?>